package com.itheima.aop;


import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Slf4j
@Component
public class TimeAspect1 {
    @SneakyThrows
    @Around("@annotation(com.itheima.aop.Log)")
    public Object around(ProceedingJoinPoint pjo) {
        long start = System.currentTimeMillis();
        Object proceed = pjo.proceed();
        long end = System.currentTimeMillis();
        log.info("{}类{}执行方法用时{}毫秒",pjo.getClass(),pjo.getSignature().getName(),start-end);
        return proceed;
    }


}
